package com.medical.doctor.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.medical.doctor.entity.DoctorGradeEntity;
import com.medical.doctor.service.DoctorGradeService;
import com.medical.common.utils.PageUtils;
import com.medical.common.utils.R;



/**
 * 
 *
 * @author wen
 * @email 1023076426@qq.com
 * @date 2021-08-13 20:09:06
 */
@RestController
@RequestMapping("doctor/doctorgrade")
public class DoctorGradeController {
    @Autowired
    private DoctorGradeService doctorGradeService;

    /**
     * 所有科室下的医生级别
     */
    @RequestMapping("/list/{departmentId}")
    public R listByDepartmentId(@RequestParam Map<String, Object> params,@PathVariable("departmentId")Integer departmentId){
        PageUtils page = doctorGradeService.queryPageById(params,departmentId);

        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = doctorGradeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{gradeId}")
    public R info(@PathVariable("gradeId") Integer gradeId){
		DoctorGradeEntity doctorGrade = doctorGradeService.getById(gradeId);

        return R.ok().put("doctorGrade", doctorGrade);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DoctorGradeEntity doctorGrade){
		doctorGradeService.save(doctorGrade);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DoctorGradeEntity doctorGrade){
		doctorGradeService.updateById(doctorGrade);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] gradeIds){
		doctorGradeService.removeByIds(Arrays.asList(gradeIds));

        return R.ok();
    }

}
